package com.xzq.bizimpl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.xzq.biz.UserBiz;
import com.xzq.dao.AuthorityDao;
import com.xzq.dao.UserDao;
import com.xzq.entity.Authority;
import com.xzq.entity.Page;
import com.xzq.entity.User;
@Service
public class UserBizImpl implements UserBiz {
	@Resource
	private UserDao dao;
	@Resource
	private AuthorityDao adao;
	@Override
	public int addUser(User user) {
		Authority a = new Authority();
		a.setId(1);
		a = adao.findOneAuthority(a);
		user.setAuthority(a);
		int count = dao.regist(user);
		return count;
	}

	@Override
	public User findOneUserByLogin(User user) {
		user = dao.login(user);
		return user;
	}

	@Override
	public int modifyUser(User user) {
		int count = dao.modifyUser(user);
		return count;
	}

	@Override
	public int modifyUserAuthorityByAdmin(User user, int type) {
		int count = dao.modifyUserAuthorityByAdmin(user, type);
		return count;
	}

	@Override
	public Page findAllUserByAdmin(Page page) {
		page = dao.findAllUserByAdmin(page);
		return page;
	}

	@Override
	public User findOneUser(User user) {
		user = dao.login(user);
		return user;
	}

}
